home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / SSAVER.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-30  |  3.1 KB  |  155 lines

  1. #ifdef MSDOS
  2. #include <conio.h>
  3. #endif
  4. #include "global.h"
  5. #ifdef SCREENSAVER
  6. #include "commands.h"
  7. #include "session.h"
  8.  
  9. #if !defined(_lint)
  10. static char rcsid[] OPTIONAL = "$Id: ssaver.c,v 1.16 1997/07/31 00:44:20 root Exp root $";
  11. #endif
  12.  
  13. #if defined(TNOS_68K) || defined(UNIX)
  14. extern unsigned char SCREENwidth;
  15. #endif
  16. extern unsigned char SCREENlength;
  17. int32 LastIO;
  18. static int32 ScreenSaver = 0;
  19. static int ss_line, state, delayit, statline;
  20.  
  21. extern void statLineToggle (int clearmarquee);
  22. #if !defined(TNOS_68K) && !defined(UNIX)
  23. void setscreens (int back, int fore, int clr);
  24. #endif
  25.  
  26.  
  27. #if defined(TNOS_68K) || defined(UNIX)
  28. #undef tputs
  29. #undef newscreen
  30. /*lint -save -e659 */
  31. #undef newscreen
  32. #ifdef HAVE_NCURSES_H
  33. #include <ncurses.h>
  34. #else
  35. #include <curses.h>
  36. #endif
  37. /*lint -restore */
  38. static WINDOW *saved;
  39. #ifdef TNOS_68K
  40. extern short UseCurses;
  41. #endif
  42. #ifdef TNOS_68K
  43. extern chtype MY_NORMAL;
  44. #endif
  45. #endif
  46.  
  47. #ifdef UNIX
  48. extern int16 intrace;
  49. #endif
  50.  
  51.  
  52. #define DELAYVAL 2
  53.  
  54. void
  55. screensaver ()
  56. {
  57. #ifdef UNIX
  58. static short back, fore;
  59. #endif
  60.  
  61.     if (!ScreenSaver)
  62.         return;
  63. #ifdef TNOS_68K
  64.     if (!UseCurses)
  65.         return;
  66. #endif
  67.     if (secclock() > (LastIO + ScreenSaver))    {
  68.         if (!state)    {
  69.             statline = Current->screen->statline;
  70.             if (statline)
  71.                 statLineToggle (1);
  72.             state = 1;
  73. /* next line is a problem for linux version */
  74.             swapscreen (Current, NULLSESSION);
  75. #if defined(TNOS_68K) || defined(UNIX)
  76.             saved = newwin (SCREENlength, SCREENwidth, 0, 0);
  77. #ifdef TNOS_68K
  78.             wattrset (saved, MY_NORMAL);
  79. #else
  80.             (void) pair_content (1, &fore, &back);
  81.             (void) init_pair (1, COLOR_WHITE, COLOR_BLACK);
  82.             wattrset (saved, COLOR_PAIR(1));
  83.             (void) wbkgd (saved, COLOR_PAIR(1));
  84. #endif
  85.             (void) leaveok (saved, 1);
  86. #else
  87.             _setcursortype (_NOCURSOR);
  88. #endif
  89.             ss_line = delayit = 0;
  90.         }
  91.         if (!delayit++)    {
  92. #if !defined(TNOS_68K) && !defined(UNIX)
  93.             setscreens (0, 7, 1);
  94.             gotoxy (12, ++ss_line);
  95.             ss_line %= SCREENlength;
  96.             printf (" TNOS Screen Saver Active... Press any key to continue ");
  97.             (void) fflush (stdout);
  98. #else
  99.             (void) werase (saved);
  100.             (void) wmove (saved, ss_line++, 12);
  101.             ss_line %= SCREENlength;
  102.             (void) waddstr (saved, " TNOS Screen Saver Active... Press any key to continue ");
  103.             (void) wrefresh (saved);
  104. #endif
  105.         }
  106.         delayit %= DELAYVAL;
  107.     } else if (state)    {
  108. #if defined(TNOS_68K) || defined(UNIX)
  109.         (void) delwin (saved);
  110. #endif
  111.         swapscreen (NULLSESSION, Current);
  112.         state = 0;
  113. #if defined(TNOS_68K) || defined(UNIX)
  114.         _setcursortype (_NORMALCURSOR);
  115. #endif
  116. #ifdef UNIX
  117.         (void) init_pair (1, fore, back);
  118. #endif
  119.         if (statline)
  120.             statLineToggle(1);
  121.     }
  122. }
  123.  
  124. /* set the screen saver value */
  125. int dossaver(int argc, char *argv[], void *p OPTIONAL)
  126. {
  127.     LastIO = secclock();
  128.     return setlong(&ScreenSaver,"Screen Saver delay (seconds)",argc,argv);
  129.  
  130. }
  131.  
  132. void
  133. sskick()
  134. {
  135. #ifdef UNIX
  136.  
  137.     if (!intrace && ScreenSaver)    {
  138. #else
  139.     if (ScreenSaver)    {
  140. #endif
  141.         LastIO = secclock();
  142.         if (state)
  143.             screensaver();
  144.     }
  145. }
  146.  
  147. int
  148. ssenabled ()
  149. {
  150.     return state;
  151. }
  152.  
  153. #endif /* SCREENSAVER */
  154.  
  155.